package springBoot.akai.Akai.Mapper;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import springBoot.akai.Akai.Entity.Video;

import java.util.List;

@Mapper
@Repository
public interface VideoMapper {
    @Select("SELECT * FROM Video ORDER BY id DESC")
    List<Video> selectAll();

    @Select("SELECT * FROM Video WHERE id=#{id}")
    Video selectById(int id);

    @Insert("INSERT INTO Video(name, description, cover, filepath, duration, size, release_date) " +
            "VALUES(#{name}, #{description}, #{cover}, #{filepath}, #{duration}, #{size}, #{release_date})")
    boolean insert(Video video);
    
    @Update("UPDATE Video SET name=#{name},description=#{description},cover=#{cover},filepath=#{filepath}," +
    		"duration=#{duration},size=#{size},release_date=#{release_date} WHERE id=#{id}")
    boolean update(Video video);

    @Delete("DELETE FROM Video WHERE id=#{id}")
    boolean deleteById(int id);
}
